#include <iostream>
#include <vector>
using namespace std;
#define int long long
signed main() {
    int n, p;
    cin >> n >> p;
    vector<int> a(n + 1, 0);
    for(int i = 1; i <= n; i++) {
        int temp;
        cin >> temp;
        a[i] = temp;
    }
    vector<int> b(n + 2, 0);
    for(int i = 1; i <= n; i++) {
        b[i] = a[i] - a[i - 1];
    }
    for(int i = 0; i < p; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        b[x] += z;
        b[y + 1] -= z;
    }
    vector<int> c(n + 1, 0);
    int ret = 0x3f3f3f3f;
    for(int i = 1; i <= n; i++) {
        c[i] = b[i] + c[i - 1];
        ret = min(ret, c[i]);
    }
    cout << ret << endl;
    return 0;
}